
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="软件园商城 - 新增用户">
    <meta name="author" content="">
    <title>新增货物 | 软件园商城</title>
    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <!-- Custom styles -->
    <link href="css/dashboard.css" th:href="@{/css/dashboard.css}" rel="stylesheet">
    <style type="text/css">
        :root {
            --primary-color: #4e73df;
            --secondary-color: #f8f9fc;
            --accent-color: #2e59d9;
            --text-color: #5a5c69;
            --error-color: #e74a3b;
            --success-color: #1cc88a;
        }

        body {
            background-color: #f8f9fc;
            color: var(--text-color);
            font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        }

        .card {
            border: none;
            border-radius: 0.35rem;
            box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
            margin-bottom: 1.5rem;
        }

        .card-header {
            background-color: var(--primary-color);
            color: white;
            border-bottom: none;
            padding: 1rem 1.35rem;
            border-radius: 0.35rem 0.35rem 0 0 !important;
        }

        .form-container {
            max-width: 600px;
            margin: 0 auto;
            padding: 2rem;
            background: white;
            border-radius: 0.35rem;
            box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
        }

        .form-group {
            margin-bottom: 1.5rem;
        }

        .form-label {
            font-weight: 600;
            margin-bottom: 0.5rem;
            color: var(--text-color);
            display: flex;
            align-items: center;
        }

        .required-field::after {
            content: "*";
            color: var(--error-color);
            margin-left: 0.25rem;
        }

        .form-control {
            padding: 0.75rem 1rem;
            border: 1px solid #d1d3e2;
            border-radius: 0.35rem;
            transition: border-color 0.3s ease;
        }

        .form-control:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
        }

        .radio-group {
            display: flex;
            align-items: center;
            gap: 1.5rem;
            margin-top: 0.5rem;
        }

        .radio-option {
            display: flex;
            align-items: center;
            cursor: pointer;
        }

        .radio-option input[type="radio"] {
            margin-right: 0.5rem;
            width: 1.2em;
            height: 1.2em;
            cursor: pointer;
        }

        .btn-submit {
            background-color: var(--success-color);
            border-color: var(--success-color);
            color: white;
            padding: 0.75rem 1.5rem;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .btn-submit:hover {
            background-color: #17a673;
            border-color: #17a673;
            transform: translateY(-1px);
        }

        .btn-submit:focus {
            box-shadow: 0 0 0 0.2rem rgba(28, 200, 138, 0.5);
        }

        .hint-text {
            font-size: 0.85rem;
            margin-top: 0.25rem;
            color: #6c757d;
        }

        .error-hint {
            color: var(--error-color);
        }

        .page-title {
            font-weight: 600;
            color: var(--primary-color);
            margin-bottom: 1.5rem;
            display: flex;
            align-items: center;
        }

        .page-title i {
            margin-right: 0.75rem;
            font-size: 1.5rem;
        }

        /* Animation */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .animated-content {
            animation: fadeIn 0.5s ease-out;
        }

        /* Responsive adjustments */
        @media (max-width: 768px) {
            .form-container {
                padding: 1.5rem;
            }

            .radio-group {
                flex-direction: column;
                align-items: flex-start;
                gap: 0.5rem;
            }
        }
    </style>

    <script>
        function validateForm() {
            const type = document.getElementsByName('type')[0].value;
            const number = document.getElementsByName('number')[0].value;
            let isValid = true;
            // 验证货物类型
            if (type.trim() === "") {
                alert("货物类型不能为空，请输入有效的货物类型。");
                document.getElementsByName('type')[0].focus();
                return false;
            }

            // 验证数量
            if (number.trim() === "") {
                alert("数量不能为空，请输入有效的数量。");
                document.getElementsByName('number')[0].focus();
                return false;
            }
            return true;
        }

        // 增强表单交互
        document.addEventListener('DOMContentLoaded', function() {
            // 输入框焦点效果
            const inputs = document.querySelectorAll('.form-control');
            inputs.forEach(input => {
                input.addEventListener('focus', function() {
                    this.parentElement.querySelector('.form-label').style.color = 'var(--primary-color)';
                });
                input.addEventListener('blur', function() {
                    this.parentElement.querySelector('.form-label').style.color = 'var(--text-color)';
                });
            });

        });
    </script>
</head>

<body>
<!--顶部菜单 -->
<div th:replace="muen :: headmeun"></div>
<div class="container-fluid">
    <div class="row">
        <!--左菜单 -->
        <div th:replace="muen :: #sidebarMenu(lurl='shoptrue')"></div>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4 animated-content">
            <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-3 mb-4 border-bottom">
                <h1 class="page-title">
                    <i class="fas fa-user-plus"></i>新增货物
                </h1>
            </div>

            <div class="form-container">
                <form action="#" th:action="@{/addShop}" method="post" onsubmit="return validateForm();">
                    <div class="form-group">
                        <label class="form-label required-field">货物类型:</label>
                        <input type="text" class="form-control" name="type" placeholder="请输入货物类型" required/>
                        <div class="hint-text error-hint">* 必填字段</div>
                    </div>
                    <div class="form-group">
                        <label class="form-label required-field">数量:</label>
                        <input type="number" class="form-control" name="number" placeholder="请输入货物数量 (Kg)" min="0" max="150" required/>
                        <div class="hint-text error-hint">* 必填字段</div>
                    </div>

                    <div class="form-group text-right">
                        <button type="submit" class="btn btn-submit">
                            <i class="fas fa-check-circle mr-2"></i>确认添加
                        </button>
                        <a href="#" class="btn btn-outline-secondary ml-2" th:href="@{/shopPage}+'/1'+'/5'">
                            <i class="fas fa-times mr-2"></i>取消
                        </a>
                    </div>
                </form>
            </div>
        </main>
    </div>
</div>

<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="js/jquery-3.2.1.slim.min.js" th:src="@{/js/jquery-3.2.1.slim.min.js}"></script>
<script type="text/javascript" src="js/popper.min.js" th:src="@{/js/popper.min.js}"></script>
<script type="text/javascript" src="js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>

<!-- Icons -->
<script type="text/javascript" src="js/feather.min.js" th:src="@{/js/feather.min.js}"></script>
<script>
    feather.replace()
</script>

<!-- Custom scripts -->
<script>
    $(document).ready(function() {
        // 增强表单验证体验
        $('form').on('submit', function(e) {
            if (!validateForm()) {
                e.preventDefault();
                return false;
            }
            // 可以在这里添加加载动画
            $('.btn-submit').html('<i class="fas fa-spinner fa-spin mr-2"></i>提交中...');
            return true;
        });
    });
</script>

</body>
</html>